#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#include<sys/types.h>

char* const addenv[] = {
    (char* const)"MYVAL=123456789", NULL 
};

int main()
{
    printf("我的程序要运行了\n");
    if(fork() == 0) //子进程
    {
        char* const argv[] = {
            (char* const)"other", (char* const)"-a",
            (char* const)"-b", NULL 
        };

        for(int i = 0; addenv[i]; i++)
        {
            putenv(addenv[i]);
        }
        
        extern char** environ;
        execvpe("./other", argv, environ);
        //execvp("./other", argv);
        exit(1);
    }
    //父进程
    waitpid(-1, NULL, 0);
    printf("我的程序运行完毕\n");

    return 0;
}
